﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using BusinessLayer.FindArtInfo.Entities;
using DBHelper;

namespace BusinessLayer.FindArtInfo
{
    public class ArtLinksBL
    {
        public List<ArtLinks> GetByCategory(int categoryId)
        {
            List<ArtLinks> result = new List<ArtLinks>();
            var adapter = new BaseDAO(DbConfig.DbFindArtInfoConnectionString);
            adapter.AddParameter("@CategoryId", categoryId);           
            try
            {
                result = adapter.GetList<ArtLinks>("sp_ArtLinks_Select_By_Category", CommandType.StoredProcedure, CustomConnectionState.CloseOnExit);
            }
            catch (Exception)
            {
            }
            finally { adapter.Dispose(); }
            return result;
        }

        public List<ArtLinks> Search(string keyWord,int? categoryId,int? countryId)
        {
            List<ArtLinks> result = new List<ArtLinks>();
            var adapter = new BaseDAO(DbConfig.DbFindArtInfoConnectionString);
            adapter.AddParameter("@KeyWord", keyWord);
            adapter.AddParameter("@CategoryId", categoryId);
            adapter.AddParameter("@CountryId", countryId);
            try
            {
                result = adapter.GetList<ArtLinks>("sp_ArtLinks_Search", CommandType.StoredProcedure, CustomConnectionState.CloseOnExit);
            }
            catch (Exception)
            {
            }
            finally { adapter.Dispose(); }
            return result;
        }
    }
}
